package com.tsvetanv.simpleformcontroller.example01.person.mvc.model;

public class Name {
	private String firstName;
	private String lastName;

	// --- Constructors, Getters/Setters ---------------------------------------
	public Name() {
	}

	public Name(String firtsName, String lastName) {
		this.firstName = firtsName;
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	// ---- Auxiliary methods --------------------------------------------------
	@Override
	public String toString() {
		return firstName + " " + lastName;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Name)) {
			throw new IllegalArgumentException(
					"Illegal input parameter for equality testing.");
		}
		Name nameObj = (Name) obj;
		boolean isEqualFirstName = firstName.equalsIgnoreCase(nameObj
				.getFirstName());
		boolean isEqualLastName = lastName.equalsIgnoreCase(nameObj
				.getLastName());

		return isEqualFirstName && isEqualLastName;
	}

}
